use std::error::Error;

use serde_derive::{Deserialize, Serialize};
use serde_json::json;

#[derive(Debug, Deserialize)]
struct DatabaseConfig {
    url: String,
}

#[derive(Debug, Deserialize)]
struct ServerConfig {
    host: String,
    port: u16,
}

#[derive(Debug, Deserialize)]
struct AppConfig {
    database: DatabaseConfig,
    server: ServerConfig,
}

// #[actix_web::main]
fn main() -> std::io::Result<()> {

    // // env::set_var("CARGO_BUILD_PIPELINES", "nosign");
    //
    // let config =  Config::builder()
    //     .add_source(File::from(Path::new("resource/config.json")))
    //     .build()
    //     .unwrap();
    //
    // let result = config.try_deserialize::<AppConfig>();
    //
    // println!("{:?}", result);

    let d: Result<TokenBodyResponse, serde_json::error::Error> = serde_json::from_value(
        json!({ "token": TokenBodyResponse::gen(), "token_type": "bearer" }),
    );

    println!("{:?}", d);

    Ok(())
}
#[derive(Serialize, Deserialize,Debug)]
pub struct TokenBodyResponse {
    pub token: String,
    pub token_type: String,
}

impl TokenBodyResponse {
    fn gen()->String{
        let result = Err("");
        result.unwrap()
    }
}
